package com.ops.chirpit;

import org.json.JSONArray;



public class AccountType {

	public int id;
	public String name;
	public String prefix;
	public int drawable;

	public AccountType(int i, String n, String p, int d) {
	    id = i;
	    name = n;
	    prefix = p;
	    drawable = d;
	}
	
	public static int getDrawable(int id){
		int drawable = 0;
		switch(id){
	  	case ChirpItActivity.FACEBOOK:
		  drawable = R.drawable.facebook;
		  break;
	  	case ChirpItActivity.TWITTER:
	  		drawable = R.drawable.twitter;
	  		break;
	  	case ChirpItActivity.FOURSQUARE:
	  		drawable = R.drawable.foursquare;
	  		break;
	  	case ChirpItActivity.MYSPACE:
	  		drawable = R.drawable.myspace;
	  		break;
	  	case ChirpItActivity.LINKEDIN:
	  		//drawable = R.drawable.linkedin;
	  		break;
	  	case ChirpItActivity.GOOGLEPLUS:
	  		//drawable = R.drawable.twitter;
	  		break;
	  }
		return drawable;
	}

	public static AccountType[] setAccountTypes() {
		final String[] accountNames = {"Twitter", "Facebook", "Foursquare"/*, "MySpace", "LinkedIn", "Google+"*/};
		final String[] accountPrefix = {"tw", "fb", "fs", "ms", "li", "gp"};
		AccountType[] accountTypes = new AccountType[accountNames.length];
		ChirpItActivity.attachFriends = new JSONArray[accountNames.length];
		ChirpItActivity.attachPlace = new String[accountNames.length];
		for(int i = 0; i < accountNames.length; i++){	
			accountTypes[i] = new AccountType(i, accountNames[i], accountPrefix[i], getDrawable(i));
			ChirpItActivity.attachFriends[i] = new JSONArray();
		}
		
		return accountTypes;
	}

    public static int getPrefixIndex(String string){
    	String prefix = string.substring(0, 2);
    	int prefixIndex = 0;
    	for (AccountType aP : ChirpItActivity.accountTypes){
    		if (aP.prefix.equals(prefix))
    			return prefixIndex;
    		prefixIndex++;
    	}
    	return (-1);
    }

    public static int getNameIndex(String string){
    	String name = string.toLowerCase();
    	int nameIndex = 0;
    	for (AccountType aN : ChirpItActivity.accountTypes){
    		if (aN.name.toLowerCase().equals(name))
    			return nameIndex;
    		nameIndex++;
    	}
    	return (-1);
    }
}
